#pragma once
#ifndef VECTOR2_H_
#define VECTOR2_H_

#include <math.h>

namespace EPOC
{
	class Vector2
	{
	public:
		Vector2() : m_fX(0.0f), m_fY(0.0f){};
		Vector2(float fX, float fY) : m_fX(fX), m_fY(fY){};

		virtual float Length()				{ return sqrtf( ( m_fX * m_fX ) + ( m_fY * m_fY )); }
		virtual float LengthSq()			{ return ( m_fX * m_fX ) + ( m_fY * m_fY ); }
		virtual void Normalize()			{ float fLength = Length(); m_fX /= fLength; m_fY /= fLength;}
		virtual Vector2 NormalizeCopy()		{ Vector2 vNormalized; float fLength = Length(); vNormalized.m_fX = m_fX / fLength; vNormalized.m_fY = m_fY / fLength; return vNormalized; }

		virtual float DotProduct(Vector2 *pVector)	{ return m_fX * pVector->m_fX + m_fY * pVector->m_fY; }
		virtual Vector2 Perpendicular()				{ Vector2 vPerpendicular; vPerpendicular.m_fX = -m_fY; vPerpendicular.m_fY = m_fX; return vPerpendicular; }
		
		const Vector2 Vector2::operator+(const Vector2 &other) const 
		{
			Vector2 result = *this;  

			result.m_fX += other.m_fX;
			result.m_fY += other.m_fY;
		
			return result;            
		}

		const Vector2 Vector2::operator-(const Vector2 &other) const 
		{
			Vector2 result = *this;  
			
			result.m_fX -= other.m_fX;
			result.m_fY -= other.m_fY;
		
			return result;           
		}

		const Vector2 Vector2::operator*(const float &other) const 
		{
			Vector2 result = *this; 
			result.m_fX *= other;
			result.m_fY *= other;
		
			return result;           
		}

		const Vector2 Vector2::operator/(const float &other) const 
		{
			Vector2 result = *this; 
			result.m_fX /= other;
			result.m_fY /= other;
		
			return result;           
		}

		Vector2& Vector2::operator+=(const Vector2& right)
		{
			*this = *this + right;
			return *this;
		}

		Vector2& Vector2::operator-=(const Vector2& right)
		{
			*this = *this - right;
			return *this;
		}

		Vector2& Vector2::operator*=(const float& right)
		{
			*this = *this * right;
			return *this;
		}

		Vector2& Vector2::operator/=(const float& right)
		{
			*this = *this / right;
			return *this;
		}

		bool Vector2::operator==(const Vector2 &other) const 
		{
			return (this->m_fX == other.m_fX && this->m_fY == other.m_fY);
		}

		bool Vector2::operator!=(const Vector2 &other) const 
		{
			return !(*this == other);
		}

	public:
		float m_fX;
		float m_fY;
	
	}; // class Vector2
}; // namespace EPOC

#endif